# -*- coding: utf-8 -*-

from datetime import timedelta
from utils.operators.cluster_for_spark_sql_hook_test_for_airflow_bug_operator import SparkSqlOperator
# from jms.dwd.dwd_warhouse.dwd_wide_unsign_summary_waybill_dt import jms_dwd__dwd_wide_unsign_summary_waybill_dt
# # from jms.dwd.oms.dwd_oms_order_dt import jms_dwd__dwd_oms_order_dt
# from jms.dim.dim_network_whole_massage import jms_dim__dim_network_whole_massage
# # from jms.dm.route.dm_route_selected import dm__dm_route_whole_selected
# from jms.dim.tab.dim_tab_platform_effect_config_base import jms_dim__dim_tab_platform_effect_config_base
# from jms.dwd.oms.dwd_oms_waybill_dt import jms_dwd__dwd_oms_waybill_dt
# from jms.dwd.tab.dwd_tab_barscan_deliver_base_dt import jms_dwd__dwd_tab_barscan_deliver_base_dt
# from jms.dim.dim_lmdm_sys_special_time_limit_base import jms_dim__dim_lmdm_sys_special_time_limit_base
# from jms.dim.dim_lmdm_sys_second_code import jms_dim__dim_lmdm_sys_second_code
# from jms.dim.dim_lmdm_sys_first_code import jms_dim__dim_lmdm_sys_first_code
# from jms.dwd.dwd_terminal_sign_all_detail_new_dt import jms_dwd__dwd_terminal_sign_all_detail_new_dt
from jms_route_test.dm.dm_prescription_reach_pre_details_dt import jms_dm__dm_prescription_reach_pre_details_dt

jms_dm__dm_prescription_reach_details_dt = SparkSqlOperator(
    task_id='jms_dm__dm_prescription_reach_details_dt',
    email=['jokic.wang@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    task_concurrency=1,
    pool_slots=2,
    master='yarn',
    name='jms_dm__dm_prescription_reach_details_dt_{{ execution_date | date_add(1) | cst_ds }}',
    # sla=timedelta(hours=7),
    driver_memory='10G',
    executor_memory='22G',
    executor_cores=6,
    num_executors=84,
    sql='jms_route_test/dm/dm_prescription_reach_details_dt/execute.hql',
    conf={'spark.dynamicAllocation.enabled': 'false',  # 动态资源开启
          'spark.shuffle.service.enabled': 'false',  # 动态资源 Shuffle 服务开启
          'spark.dynamicAllocation.maxExecutors': 100,  # 动态资源最大扩容 Executor 数
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
          'spark.executor.memoryOverhead': '4G',  # 堆外内存
          'spark.sql.shuffle.partitions': 1000,
          'spark.executor.extraJavaOptions': '-XX:+UseG1GC -XX:ParallelGCThreads=6'
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions': 50,  # 每天生成 50 个分区
              'hive.exec.max.dynamic.partitions.pernode': 50,  # 每天生成 50 个分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(hours=1),
)

jms_dm__dm_prescription_reach_details_dt << [
    # jms_dwd__dwd_wide_unsign_summary_waybill_dt,
    # jms_dwd__dwd_oms_waybill_dt,
    # jms_dim__dim_network_whole_massage,
    # jms_dim__dim_tab_platform_effect_config_base,
    # jms_dwd__dwd_tab_barscan_deliver_base_dt,
    # jms_dim__dim_lmdm_sys_special_time_limit_base,
    # jms_dim__dim_lmdm_sys_second_code,
    # jms_dim__dim_lmdm_sys_first_code,
    # jms_dwd__dwd_terminal_sign_all_detail_new_dt,
    jms_dm__dm_prescription_reach_pre_details_dt
]

